<template>
  <div id="date">
    <div class="calendar">
      <div class="calendar-header">
        <div class="titleName">{{ info.name }}</div>
        <div class="usefulLife">有效期 {{ info.active_start }} 至 {{ info.active_end }}</div>
        <div class="headTime">
          <div class="icon-operate" @click="handlePreMonth">
            <img src="@/assets/images/taskPackage/left@2x.png" alt="" />
          </div>
          <div class="calender-header-date">{{ currentYear }}年{{ currentMonth }}月</div>
          <div class="icon-operate" @click="handleNextMonth">
            <img src="@/assets/images/taskPackage/right@2x.png" alt="" />
          </div>
        </div>
      </div>
      <div class="calendar-body">
        <div class="calendar-week flex-wrap">
          <div v-for="(item, index) in weekList" :key="index" class="days-col" style="color: #1b1b1b;">{{ item }}</div>
        </div>
        <div class="calendar-days flex-wrap">
          <div
            @click="tapDay(item)"
            v-for="(item, index) in monthDayList"
            :key="index"
            :class="{
              'days-col': true,
              'is-signed': item ? isSigned(item.date, info.day_list) : false,
              'is-Nsigned': item ? !isLastDay(item.time, info.day_list) : false
            }"
          >
            <div :class="{ 
              'days-col-text': true, 'last-day': item ? isLastDay(item.time) : false, 
              'is-today': item ? (item.date == today ? true : false) : false }"
            >
              {{ item ? formatZero(item.day) : "" }}
            </div>
            <div class="isStart" v-if="item ? !isLastDay(item.time, info.day_list) : false">
              <img v-if="isSigned(item.date, info.day_list)" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fgou1%402x.png" alt="" />
              <img v-if="!isSigned(item.date, info.day_list)" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fcancel%402x.png" alt="" />
              <span>{{ isNoSigned(item.date, info.day_list) ? "开始" : "" }}{{ isNoEnd(item.date, info.day_list) ? "结束" : "" }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="tips">
        <div class="tipsSpan">
          <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fgou1%402x.png" alt="" />
          <span>表示当天已完成任务</span>
        </div>
        <div class="tipsSpan">
          <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fcancel%402x.png" alt="" />
          <span>表示当天未完成任务</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import member_datecontroller from "./member_datecontroller";
export default member_datecontroller;
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
#date {
  border-radius: 0.375rem;
  overflow: hidden;
  margin: 0 auto;
  margin-top: 0.63rem;

  .date-headed {
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;

    .left {
      width: 0;
      height: 0;
      border-top: 0.5rem solid transparent;
      border-right: 0.6rem solid#999999;
      border-bottom: 0.5rem solid transparent;
      position: relative;
      top: 0.8rem;
    }

    .right {
      width: 0;
      height: 0;
      border-top: 0.5rem solid transparent;
      border-left: 0.6rem solid#999999;
      border-bottom: 0.5rem solid transparent;
      position: relative;
      top: 0.8rem;
      transform: rotate(180edg);
    }
  }

  .calendar {
    background-color: #fff;
    border-radius: 0.31rem;

    .flex-wrap {
      display: flex;
      flex-wrap: wrap;
    }

    .calendar-header {
      text-align: center;
      font-size: 40rpx;
      overflow: hidden;
      line-height: 0.72rem;
      padding-top: 0.91rem;
      box-sizing: border-box;

      .titleName {
        font-size: 0.94rem;
        font-weight: 400;
        color: #242424;
        margin-bottom: 0.56rem;
      }

      .usefulLife {
        font-size: 0.75rem;
        font-weight: 400;
        color: #7f7f7f;
      }

      .icon-operate {
        display: flex;
        align-items: center;
        color: #666;
        font-size: 1.13rem;

        img {
          width: 0.63rem;
          height: 0.56rem;
        }
      }

      .disabled {
        color: #999;
      }

      .calender-header-date {
        display: inline-block;
        margin: 0 0.94rem;
        color: #1b1b1b;
        font-size: 0.88rem;
        font-weight: 400;
      }
    }

    .calendar-body {
      .days-col {
        margin: 0.5rem 0;
        width: 14.28%;
        text-align: center;
        font-size: 0.75rem;
      }

      .days-col-text {
        display: block;
        margin: auto;
        width: 1.875rem;
        height: 1.875rem;
        line-height: 1.875rem;
        text-align: center;
        border-radius: 100%;
        font-size: 0.75rem;
      }

      .is-signed .days-col-text {
        position: relative;
      }

      .is-Nsigned .days-col-text {
        position: relative;
      }

      .is-Nsigned .isStart {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.63rem;

        img {
          margin: 0;
          width: 0.69rem;
          height: 0.69rem;
        }

        span {
          margin-left: 0.25rem;
        }
      }
      // .is-Nsigned .days-col-text::after {
      //   position: absolute;
      //   content: "";
      //   left: 33%;
      //   bottom: -5px;
      //   width: 0.69rem;
      //   height: 0.69rem;
      //   border-radius: 50%;
      //   background-image: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fcancel%402x.png");
      //   background-repeat: no-repeat;
      //   background-size: 100%;
      // }
      // .is-signed .days-col-text::after {
      //   position: absolute;
      //   content: "";
      //   left: 33%;
      //   bottom: -5px;
      //   width: 0.69rem;
      //   height: 0.69rem;
      //   border-radius: 50%;
      //   background-image: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fgou1%402x.png");
      //   background-repeat: no-repeat;
      //   background-size: 100%;
      // }
      .last-day {
        color: #999;
      }

      .is-today {
        position: relative;
        color: #f55e55;
      }

      .is-today::before {
        position: absolute;
        content: "";
        left: 40%;
        bottom: 0;
        width: 0.25rem;
        height: 0.25rem;
        background: #f55e55;
        border-radius: 50%;
      }
    }
  }

  .headTime {
    border-radius: 0.31rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.56rem;
    margin-top: 1.53rem;
  }
}

.tips {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: 0.84rem;

  .tipsSpan:first-child {
    margin-right: 0.325rem;
  }

  .tipsSpan {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.63rem;

    img {
      width: 0.81rem;
      height: 0.78rem;
      margin: 0;
      margin-right: 0.34rem;
    }
  }
}
</style>
